<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./bootstrap.css">
    <script src="./jquery-3.6.0.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        body {
            background-image: url(./1.jpg);
            background-repeat: no-repeat;
            /* background-position-x: 200px; */
        }

        .container {
            width: 600px;
            margin-top: 100px;
            /* border: 1px solid #ddd; */
            padding: 0 20px;
        }

        .btn-primary {
            width: 100px;
            margin: 0 auto;
        }

        .header span {
            width: 50%;
            display: inline-block;
            height: 50px;
            text-align: center;
            line-height: 50px;
            font-size: 18px;
            font-weight: 600;
        }

        .header span:nth-child(1) {
            background-color: #337ab7;
            color: white;
        }

        label {
            color: white;
            margin: 20px 0;
        }

        .btn-primary {
            margin: 0 auto;
            margin-bottom: 20px;
        }

        .form-group input {
            width: 300px;
        }

        #xuxu {

            margin-top: 40px;
            float: left;
        }

        #xuxu1 {
            display: inline-block;
            margin-left: 10px;
            margin-top: 45px;
            cursor: pointer;
        }
    </style>
</head>

<body>
    <div class="container">
        <form>
            <div class="form-group">
                <label for="exampleInputEmail1">用户名</label>
                <input type="text" class="form-control username" name="username" placeholder="请输入用户名">
            </div>
            <div class="form-group">
                <label for="exampleInputPassword1">密码</label>
                <input type="password" class="form-control password" name="password" placeholder="请输入密码">
            </div>
            <!-- <div class="disnone"></div> -->

            <button type="button" class="btn btn-primary zhuce" id="xuxu">注册</button>
            <a id="xuxu1">登录</a>
        </form>
    </div>
    <script>
        const username = $(".username")
        const password = $(".password")


        $('.zhuce').on('click', function () {
            var data = {
                pwd: password.val(),
                username: username.val()

            }

            $.ajax({
                type: 'post',
                url: 'https://api.it120.cc/conner/user/username/register',
                data

            }).then(res => {
                if (res.code == 0) {
                    alert('用户注册成功')
                } else {
                    if (res.code == 600) {
                        alert('用户名密码不能为空')
                    } else {
                        alert('用户已存在')
                    }

                }
                console.log(res)
            })

        })
        $('#xuxu1').on('click', function () {
            location.href = './login.html'
        })

    </script>
</body>

<script>

</script>


</html>